Validate LogEntry metadata; increase flash z-index#257
Conversation
There was a problem hiding this comment.
Pull request overview
This PR prevents creating LogEntry records with effectively empty metadata (addressing issue #249) and attempts to ensure flash notifications render above modal overlays.
Changes:
- Added a model-level validation on
LogEntryto require at least one non-emptymetadatavalue before saving. - Increased the flash container’s z-index to avoid being covered by the modal overlay.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| app/views/shared/_flash.html.erb | Raises flash z-index to display above modal overlay. |
| app/models/log_entry.rb | Adds custom validation to block “empty” metadata submissions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add a custom validation to LogEntry to ensure at least one metadata field is present before saving. Also bump the flash partial's z-index class from z-50 to z-9999 so flash notifications render above other UI elements.
Insert an i18n-tasks-use comment into LogEntry#not_empty referencing activerecord.errors.models.log_entry.attributes.base.not_empty so i18n-tasks will detect the translation key. This is a no-op change at runtime and prevents the key from being reported as unused by static analysis.
79b7edb to
10c80df
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ea5e5d4 to
72d1a73
Compare
TL;DR
Fixes a bug where a
LogEntrycould be saved with no content. Adds a model-level validation to block empty submissions, and fixes flash notifications rendering behind the modal overlay.What is this PR trying to achieve?
Addresses #249 — a log entry could be created without any fields filled in. Clicking "Create Log Entry" on a blank form would succeed, resulting in empty records in the database.
How did you achieve it?
Added a custom validate method at_least_one_metadata_field_present that checks whether the metadata JSON column contains at least one non-blank value. If all fields are empty, an error is added to :base and the save is blocked.
Checklist